package com.mtsmda.ws.rest.jboss.services;

import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

@Path("/form")
public class FormService {
	
	@POST
	@Path("/add")
	public Response add(@FormParam("number1") String number1, @FormParam("number2") String number2){
		
		number1 = number1.replaceAll(",", ".");
		number2 = number2.replaceAll(",", ".");
		
		double numberD1 = Double.parseDouble(number1);
		double numberD2 = Double.parseDouble(number2);
		
		double sum = numberD1 + numberD2;
		
		return Response.status(200).entity(new String(number1 + " + " + number2 + " = " + sum)).build();
	}
	
}